<script>
	$(function() {
		$( ".datepicker" ).datepicker();
	});
        
        $(document).ready(function(){
            $( "#jumlah-hari" ).keyup(function() {
                    var jumlah_hari = parseInt($( "#jumlah-hari" ).val());
                    var date_masuk = new Date($("#date-pesan-masuk").val())
                    
                    var d = date_masuk.getDate();
                    var m = date_masuk.getMonth();
                    var y = date_masuk.getYear();
//                    var NextDate= new Date((1900+y), (d+jumlah_hari), (m));
                    var NextDate= new Date();
                    NextDate.setDate(date_masuk.getDate()+jumlah_hari);
//                    alert(NextDate.getYear());
                    $("#date-pesan-keluar").val((NextDate.getMonth()+1)+"/"+NextDate.getDate()+"/"+(1900+NextDate.getYear()));
                    })
		
	});
	</script>
<form action="<?php echo HOME ?>checkout_kamar_process">
    <input type="hidden" id="id-kamar" name="id_kamar" value="<?php echo $data_kamar['id_kamar'] ?>"/>
    <input type="hidden" name="id_data_customer" value="<?php if($customer!=0) echo $data_customer['id']; else echo 0?>">
    <table class="tabelket" width="500px">
        <tr>
            <td class="right" width="35%">Nama kamar</td>
            <td class="left" width="65%">: <?php echo $data_kamar['nama_kamar'] ?></td>
        </tr>
        <tr>
            <td class="right"><?php echo $data_kamar['tipe_letak_kamar'] ?></td>
            <td class="left">: <?php echo $data_kamar['no_letak_kamar'] ?></td>
        </tr>
        <tr>
            <td class="right">Nomor</td>
            <td class="left">: <?php echo $data_kamar['no_kamar'] ?></td>
        </tr>
        <tr>
            <td class="right">Nomor pengenal</td>
            <td class="left">: <input name="no_pengenal" class="panjang" id="no-pengenal" value="<?php if ($customer != 0) echo $data_customer['no_pengenal'] ?>"/></td>
        <input name="status_data_customer" type="hidden" id="status-data-customer" value="-" />
        </tr>
        <tr>
            <td class="right">Jenis pengenal</td>
            <td class="left">: <select name="jenis_pengenal" id="jenis-pengenal">
                    <option <?php if ($customer != 0 && $data_customer['jenis_pengenal'] == "ktp") echo "selected" ?>>ktp</option>
                    <option <?php if ($customer != 0 && $data_customer['jenis_pengenal'] == "sim") echo "selected" ?>>sim</option>
                    <option <?php if ($customer != 0 && $data_customer['jenis_pengenal'] == "passport") echo "selected" ?>>passport</option>
                </select></td>
        </tr>
        <tr>
            <td class="right">Country of passport</td>
            <td class="left">: 
                <input class="panjang" id="country-of-passport" name="country_of_passport" value="<?php if ($customer != 0) echo $data_customer['country_of_passport'] ?>"/>
            </td>
        </tr>
        <tr>
            <td class="right">First name</td>
            <td class="left">: 
                <input class="panjang" id="first-name" name="first_name" value="<?php if ($customer != 0) echo $data_customer['first_name'] ?>"/>
            </td>
        </tr>
        <tr>
            <td class="right">Last name</td>
            <td class="left">: 
                <input class="panjang" id="last-name"  name="last_name" value="<?php if ($customer != 0) echo $data_customer['last_name'] ?>"/>
            </td>
        </tr>
    <input type="hidden" name="id_data_customer" value="<?php if($customer!=0) echo $data_customer['id']; else echo 0?>">
        <tr>
            <td class="right">Jumlah hari pesan</td>
            <td class="left">: <input type="text" class="pendek" id="jumlah-hari" /></td>
        </tr>
        <?php if($customer!=0){ 
            $temp = explode("-", $customer['date_pesan_masuk']);
            $temp2 = explode("-", $customer['date_pesan_keluar']);
            ?>
            <tr>
                <td class="right">Tanggal pesan masuk</td>
                <td class="left">: <input type="text" class="datepicker" id="date-pesan-masuk" name="date_pesan_masuk" value="<?php echo $temp[1] . "/" . $temp[2] . "/" . $temp[0] ?>"></td>
            </tr>
            <tr>
                <td class="right">Tanggal pesan keluar</td>
                <td class="left">: <input type="text" class="datepicker" id="date-pesan-keluar" name="date_pesan_keluar" value="<?php echo $temp2[1] . "/" . $temp2[2] . "/" . $temp2[0] ?>"></td>
            </tr>
        <?php } else { ?>
            <tr>
                <td class="right">Tanggal pesan masuk</td>
                <td class="left">: <input type="text" class="datepicker" id="date-pesan-masuk" name="date_pesan_masuk" value="<?php echo ($bulan + 1) . "/" . $tanggal . "/" . date("Y") ?>"></td>
            </tr>
            <tr>
                <td class="right">Tanggal pesan keluar</td>
                <td class="left">: <input type="text" class="datepicker" id="date-pesan-keluar" name="date_pesan_keluar" value="<?php echo($bulan + 1) . "/" . $tanggal . "/" . date("Y") ?>"></td>
            </tr>
        <?php } ?>
        <tr>
            <td class="right">Jumlah orang menginap</td>
            <td class="left">: <input type="text" class="pendek" name="jumlah_huni" value="<?php if ($customer != 0) echo $customer['jumlah_huni'] ?>"/></td>
        </tr>
        <input type="hidden" name="id_customer" value="<?php if($customer!=0) echo $customer['id']; else echo 0?>">
        <tr>
            <td class="right" colspan="2">Tagihan</td>
        </tr>
        <?php 
        $total_trax=-$biaya_kamar1;
        ?>
        <tr>
            <td class="right">Biaya kamar</td>
            <td class="left">: <?php echo $biaya_kamar1 ?></td>
        </tr>
        <?php
        if($customer['adjoin_to']>0)
        {
            $total_trax-=$biaya_kamar2;
            ?>
        <tr>
            <td class="right">Biaya kamar adjoin</td>
            <td class="left">: <?php echo $biaya_kamar2 ?></td>
        </tr>
            <?php
        }
        for($i=0;$i<count($trax_list);$i++) { 
            if($trax_list[$i]['jenis_trax'] == "deposit")
                $total_trax += $trax_list[$i]['harga_trax'];
            else
                $total_trax -= $trax_list[$i]['harga_trax'];
            ?>
        <tr>
            <td class="right">Transaksi</td>
            <td class="left">: 
                <?php echo ($i+1) ?>) <?php echo $trax_list[$i]['nama_trax'] ?> | <?php echo $trax_list[$i]['jenis_trax'] ?> | <?php echo $trax_list[$i]['harga_trax'] ?> | <?php echo $trax_list[$i]['keterangan'] ?><br />
            </td>
        </tr>   
        <?php } ?>
        <tr>
            <td class="right">Total</td>
            <td class="left">: <?php echo $total_trax ?></td>
        </tr>   
        <tr>
            <td class="right">Jenis pembayaran</td>
            <td class="left">: <select name="pembayaran_trax">
                    <option>Tunai</option>
                    <option>Check</option>
                </select></td>
        </tr>
        <tr>
            <td class="right">Jumlah</td>
            <td class="left">: <input name="harga_trax" /></td>
        </tr>
        <tr>
            <td class="right">Keterangan</td>
            <td class="left">: <input name="keterangan" /></td>
        </tr>
        <input name="adjoin_status" type="hidden" value="<?php echo $customer['adjoin_to']?>">
        <tr>
            <td class="right">&nbsp;</td>
            <td class="left"><input type="submit" value="Submit" class="tombol"></td>
        </tr>
    </table>
</form>